/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author xubuntu
 */
@Embeddable
public class InvitationPK implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "event_id")
    private int eventId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "user_nickname")
    private String userNickname;

    public InvitationPK() {
    }

    public InvitationPK(int eventId, String userNickname) {
        this.eventId = eventId;
        this.userNickname = userNickname;
    }

    public int getEventId() {
        return eventId;
    }

    public void setEventId(int eventId) {
        this.eventId = eventId;
    }

    public String getUserNickname() {
        return userNickname;
    }

    public void setUserNickname(String userNickname) {
        this.userNickname = userNickname;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) eventId;
        hash += (userNickname != null ? userNickname.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof InvitationPK)) {
            return false;
        }
        InvitationPK other = (InvitationPK) object;
        if (this.eventId != other.eventId) {
            return false;
        }
        if ((this.userNickname == null && other.userNickname != null) || (this.userNickname != null && !this.userNickname.equals(other.userNickname))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.InvitationPK[ eventId=" + eventId + ", userNickname=" + userNickname + " ]";
    }
    
}
